# !/bin/sh


if [ ! -d ".git" ]
then
    ../echoMessage.sh '检查到无git管理，将不会创建答案。'
else
    git checkout $branch
    ANSWER_BRANCH="$( git branch -a | grep answer )"
    if [ "$ANSWER_BRANCH" = ""  ];then
        ../echoMessage.sh '检测到无answer分支，将不会创建答案。'
    else
        git checkout answer
        tar  --exclude='.git/' -zcvf answer.zip ./*

        ../echoMessage.sh '检测到answer分支，正在创建答案。'
        curl -X PUT  \
            -F "answer=@answer.zip" \
            -F "buildNumber=${BUILD_NUMBER}" \
            $callback_url'/answerFile'
        rm answer.zip
        git checkout $branch
        ../echoMessage.sh '创建答案成功。'
    fi
fi